package com.ruoyi.task;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.quartz.SchedulerException;

import java.time.LocalDateTime;

public class MJob implements Job {

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
//        System.out.println("~~~" + DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(LocalDateTime.now()));
        Object triggerDataValue = context.getTrigger().getJobDataMap().get("triggerData1");
        Object triggerDataValue2 = context.getTrigger().getJobDataMap().get("triggerData2");
        Object jobBuilderJobDataValue = context.getJobDetail().getJobDataMap().get("jobBuilderJobData1");
        Object jobBuilderJobDataValue2 = context.getJobDetail().getJobDataMap().get("jobBuilderJobData2");
        Object schedulerValue1 = null;
        try {
            schedulerValue1 = context.getScheduler().getContext().get("schedulerData1");
        } catch (SchedulerException e) {
            throw new RuntimeException(e);
        }
        System.out.printf("triggerData1:%s%n", triggerDataValue);
        System.out.printf("triggerData2:%s%n", triggerDataValue2);
        System.out.printf("jobBuilderJobData1:%s%n", jobBuilderJobDataValue);
        System.out.printf("jobBuilderJobData2:%s%n", jobBuilderJobDataValue2);
        System.out.printf("schedulerData1:%s%n", schedulerValue1);
        System.out.println("hello:" + LocalDateTime.now());
    }
}